﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using QxFramework.Core;
using System;
using GameCombine;
using GameControl;
using GameMap;

public class GameSubmodule : Submodule
{
    //    bool isBenchOpened = false;
    protected override void OnInit(object args = null)
    {
        base.OnInit(args);


        //ManagerExample.Instance.InitModules();
        //ManagerExample1.Instance.InitModules();
        GameMapManager.Instance.InitModules();
        GameManager.Instance.InitModules();
        CombineManager.Instance.InitModules();
        ClockManager.Instance.InitModules();
        AudioControl.Instance.InitModules();


        GameMapManager.Instance.OriginLoad(GameManager.Get<IDataModule<GameSettingData>>().GameData.NeedLoadFromScene);


        foreach(var x in GameManager.Get<IDataModule<GameSettingData>>().GameData.UserWithBenchPairs)
        {


            MessageManager.Instance.Get<GameAction>().DispatchMessage(GameAction.OpenBenchUI, this, new BenchArgs
            {
                collectedItems = new List<CombinableItem>(),
                benchName = GameMapManager.Get<IMapManager>().GetPosFixedItemFieldByMeshPos(x.Item2).ItemName,
                user = x.Item1,
                interactItemName = null,
                isFinalBench = false//benchName=this.gameObject.name

            }) ;
        }
        //     CombineManager.Get<ICombineUIManager>().OpenCombineBench(new System.Tuple<string, string>("",GameMapManager.Get<IMapManager>().GetNewBenchName));
    }
    protected override void OnDestroy()
    {
        base.OnDestroy();

    }
    protected override void OnUpdate()
    {
        base.OnUpdate();

        if (Input.GetKeyDown(KeyCode.Escape))
        {
            UIManager.Instance.Open("EscList", 4);
        }
    }

}
